package com.mob.commons.deviceinfo;

import android.content.Context;
import android.content.IntentFilter;
import android.location.Location;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import com.mob.commons.g;
import com.mob.commons.k;
import com.mob.tools.MobHandlerThread;
import com.mob.tools.utils.Data;
import com.mob.tools.utils.DeviceHelper;
import com.mob.tools.utils.Hashon;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Random;

public class DeviceInfoCollector
  implements Handler.Callback
{
  private static DeviceInfoCollector a;
  private Context b;
  private DeviceHelper c;
  private Hashon d;
  private Handler e;
  private Random f;

  private DeviceInfoCollector(Context paramContext)
  {
    this.b = paramContext.getApplicationContext();
    this.c = DeviceHelper.getInstance(paramContext);
    this.d = new Hashon();
    this.f = new Random();
  }

  private void a()
  {
    a locala = new a(this);
    locala.start();
    this.e = new Handler(locala.getLooper(), this);
    this.e.sendEmptyMessage(1);
    this.e.sendEmptyMessage(2);
    this.e.sendEmptyMessage(3);
    this.e.sendEmptyMessage(5);
  }

  private void a(Location paramLocation, int paramInt)
  {
    if (paramLocation != null)
    {
      HashMap localHashMap1 = new HashMap();
      localHashMap1.put("accuracy", Float.valueOf(paramLocation.getAccuracy()));
      localHashMap1.put("latitude", Double.valueOf(paramLocation.getLatitude()));
      localHashMap1.put("longitude", Double.valueOf(paramLocation.getLongitude()));
      localHashMap1.put("location_type", Integer.valueOf(paramInt));
      HashMap localHashMap2 = new HashMap();
      localHashMap2.put("type", "LOCATION");
      localHashMap2.put("data", localHashMap1);
      localHashMap2.put("datetime", Long.valueOf(com.mob.commons.a.b(this.b)));
      g.a(this.b).a(localHashMap2);
    }
  }

  private void b()
  {
    HashMap localHashMap1 = new HashMap();
    localHashMap1.put("phonename", this.c.getBluetoothName());
    localHashMap1.put("signmd5", this.c.getSignMD5());
    if ("wifi".equals(this.c.getDetailNetworkTypeForStatic()))
    {
      localHashMap1.put("ssid", this.c.getSSID());
      localHashMap1.put("bssid", this.c.getBssid());
    }
    String str1 = Data.MD5(this.d.fromHashMap(localHashMap1));
    String str2 = k.a(this.b);
    if ((str2 == null) || (!str2.equals(str1)))
    {
      HashMap localHashMap2 = new HashMap();
      localHashMap2.put("type", "DEVEXT");
      localHashMap2.put("data", localHashMap1);
      localHashMap2.put("datetime", Long.valueOf(com.mob.commons.a.b(this.b)));
      g.a(this.b).a(localHashMap2);
      k.a(this.b, str1);
    }
  }

  private boolean c()
  {
    long l1 = k.b(this.b);
    Calendar localCalendar1 = Calendar.getInstance();
    localCalendar1.setTimeInMillis(l1);
    int i = localCalendar1.get(1);
    int j = localCalendar1.get(2);
    int k = localCalendar1.get(5);
    long l2 = com.mob.commons.a.b(this.b);
    Calendar localCalendar2 = Calendar.getInstance();
    localCalendar2.setTimeInMillis(l2);
    int m = localCalendar2.get(1);
    int n = localCalendar2.get(2);
    int i1 = localCalendar2.get(5);
    return (i != m) || (j != n) || (k != i1);
  }

  private void d()
  {
    synchronized (a)
    {
      HashMap localHashMap1 = new HashMap();
      localHashMap1.put("ssid", this.c.getSSID());
      localHashMap1.put("bssid", this.c.getBssid());
      HashMap localHashMap2 = new HashMap();
      localHashMap2.put("type", "WIFI_INFO");
      localHashMap2.put("data", localHashMap1);
      long l = com.mob.commons.a.b(this.b);
      localHashMap2.put("datetime", Long.valueOf(l));
      g.a(this.b).a(localHashMap2);
      k.a(this.b, l);
      String str = Data.MD5(this.d.fromHashMap(localHashMap1));
      k.b(this.b, str);
      return;
    }
  }

  private void e()
  {
    IntentFilter localIntentFilter = new IntentFilter();
    localIntentFilter.addAction("android.net.wifi.STATE_CHANGE");
    this.b.registerReceiver(new c(this), localIntentFilter);
  }

  private void f()
  {
    HashMap localHashMap1 = new HashMap();
    int i = -1;
    try
    {
      int j = Integer.parseInt(this.c.getCarrier());
      i = j;
      label25: localHashMap1.put("carrier", Integer.valueOf(i));
      localHashMap1.put("simopname", this.c.getCarrierName());
      localHashMap1.put("lac", Integer.valueOf(this.c.getCellLac()));
      localHashMap1.put("cell", Integer.valueOf(this.c.getCellId()));
      HashMap localHashMap2 = new HashMap();
      localHashMap2.put("type", "BSINFO");
      localHashMap2.put("data", localHashMap1);
      localHashMap2.put("datetime", Long.valueOf(com.mob.commons.a.b(this.b)));
      g.a(this.b).a(localHashMap2);
      String str = this.d.fromHashMap(localHashMap1);
      k.c(this.b, Data.MD5(str));
      long l = com.mob.commons.a.b(this.b) + 1000L * com.mob.commons.a.j(this.b);
      k.b(this.b, l);
      return;
    }
    catch (Throwable localThrowable)
    {
      break label25;
    }
  }

  private boolean g()
  {
    HashMap localHashMap = new HashMap();
    int i = -1;
    try
    {
      int j = Integer.parseInt(this.c.getCarrier());
      i = j;
      label25: localHashMap.put("carrier", Integer.valueOf(i));
      localHashMap.put("simopname", this.c.getCarrierName());
      localHashMap.put("lac", Integer.valueOf(this.c.getCellLac()));
      localHashMap.put("cell", Integer.valueOf(this.c.getCellId()));
      String str1 = Data.MD5(this.d.fromHashMap(localHashMap));
      String str2 = k.d(this.b);
      return (str2 == null) || (!str2.equals(str1));
    }
    catch (Throwable localThrowable)
    {
      break label25;
    }
  }

  public static void startCollector(Context paramContext)
  {
    try
    {
      if (a == null)
      {
        a = new DeviceInfoCollector(paramContext);
        a.a();
      }
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  public boolean handleMessage(Message paramMessage)
  {
    switch (paramMessage.what)
    {
    default:
    case 1:
    case 2:
      do
      {
        do
          return false;
        while (!com.mob.commons.a.h(this.b));
        b();
        return false;
      }
      while (!com.mob.commons.a.m(this.b));
      if (c())
        d();
      e();
      return false;
    case 3:
      if (com.mob.commons.a.i(this.b))
        f();
      int j = 180 + this.f.nextInt(120);
      this.e.sendEmptyMessageDelayed(4, j * 1000);
      return false;
    case 4:
      if ((com.mob.commons.a.i(this.b)) && ((com.mob.commons.a.b(this.b) + 1000L * com.mob.commons.a.j(this.b) < com.mob.commons.a.b(this.b)) || (g())))
        f();
      int i = 180 + this.f.nextInt(120);
      this.e.sendEmptyMessageDelayed(4, i * 1000);
      return false;
    case 5:
    }
    if (com.mob.commons.a.k(this.b))
    {
      a(this.c.getLocation(30, 0, true), 1);
      a(this.c.getLocation(0, 15, true), 2);
    }
    this.e.sendEmptyMessageDelayed(5, 1000 * com.mob.commons.a.l(this.b));
    return false;
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.mob.commons.deviceinfo.DeviceInfoCollector
 * JD-Core Version:    0.6.2
 */